<?php
class AccounttypeModel extends AbstractModel
{
	public function __construct()
	{
		parent::__construct('account_type');
	}
	
	protected function _setFields()
	{
		return array(
			'AID',
			'AccountTypeName',
			'Status',
			'CreateDate',
			'Remark'
		);
	}
	
	protected function _setPrimaryKeys()
	{
		return array(
			'AID'
		);
	}
	
	protected function _setAutoIncrementFields()
	{
		return array(
			'AID'
		);
	}
	
	protected function _setForeignKeyRelation()
	{
		return array();
	}
	
	public function add($data)
	{
		$data = $this->_getFieldsData($data);
		$dbMaster = DB::getMaster();
		$sql = "INSERT INTO `{$this->_table}`(`AccountTypeName`,`Status`,`CreateDate`,`Remark`) 
				VALUES('{$data['AccountTypeName']}','{$data['Status']}','{$data['CreateDate']}','{$data['Remark']}')";
		$res = $dbMaster->exec($sql);
		return $res;
	}
	
	public function getAll()
	{
		$dbSlave = DB::getSlave();
		$sql = "SELECT * FROM `{$this->_table}` WHERE Status = 1";
		return $dbSlave->query($sql);
	}

	protected function _validationField($fieldName, $value) 
	{
		return true;
	}
	
	public function __destruct()
	{
		//echo 'account model destruct!';
	}
}